import { Component, Inject, OnInit, ViewChild } from '@angular/core';
import { ControlWidget } from '@delon/form';
import { ItcoreConnectionComponent } from '@shared/itcore/components/common/db/connection.component';
import { ItcoreDbColumnFilterComponent } from '@shared/itcore/components/common/db/db-column-filter.component';
import { NzUploadFile } from 'ng-zorro-antd/upload';
import { Observable, Observer } from 'rxjs';

@Component({
  selector: 'app-itcore-db-cnnect',
  template: `
    <sf-item-wrap [id]="id" [schema]="schema" [ui]="ui" [showError]="showError" [error]="error" [showTitle]="schema.title">
        <app-itcore-db-column-fliter #filter [isSelectDate]="isSelectDate" [value]='value' (submitSuccess)='submitSuccess($event)' [connectOption]='currentConnectOption'></app-itcore-db-column-fliter>
    </sf-item-wrap>
  `,
  styles: [
    `
    `,
  ],
})
// 选择数据连接
export class DBColumnFilterWidgetComponent extends ControlWidget implements OnInit {
  static readonly KEY = 'itcore-db-column-filter';

  currentConnectOption: any;
  isSelectDate: boolean;

  @ViewChild('filter') filter: ItcoreDbColumnFilterComponent;

  closeDrawer() {
  }
  ngOnInit(): void {

    this.isSelectDate = this.ui.isSelectDate;
    this.currentConnectOption = this.ui.option;
  }
  change(value: any) {

    this.setValue(value);
    if (this.ui.change) {
      this.ui.change(value);
    }
  }
  reset(value: any) {
    if (value) {
      this.filter.reset(value);
    }
  }

  submitSuccess(value) {
    this.change(value);
  }

}
